/* Copyright (C) 2014-2015 Mammoth Inc. */

var m = new M("settings");

$(function() {
	var _i = 5;
	var timer = function() {
		setInterval(function() {
			if(_i > 0) {
				$("#mm_temp_timer").html(--_i);
			} else {
				window.location.href = "http://passport.mengma.com/logout/";
			}
		}, 1000);
	}
	var sizeBottom = function() {
		var m = $(window).height() - $(".mm_navbar").height() - $(".mm_middle").height() - 250;
		if (m > 0) {
			$(".mm_bottom").css("margin-top", m + "px");
		}
	}
	sizeBottom();
	$(".mm_cog_l_list").find("li").click(function() {
		$(".mm_cog_item").eq($(this).data("id")).addClass("mm_cog_active").siblings().removeClass("mm_cog_active");
		$(this).addClass("mm_cog_list_active").siblings().removeClass("mm_cog_list_active");
		sizeBottom();
	});
	if ($("#mm_cog_province").data("p") == "- 请选择 - 城市"|| $("#mm_cog_province").data("p") == " ") {
		$("#mm_cog_province").html("何方神圣？");
	}
	/**  PERSONAL MODIFY  **/
	$("#mm_personal_cancel").click(function() {
		$("#mm_cog_personal_modify").css("display", "none");
		$("#mm_cog_personal").css("display", "block");
	});
	$("#mm_modi_username").focus(function() {
		$("#mm_modi_username").removeClass("mm_cog_error");
	});
	$("#mm_nodi_birthday").click(function() {
		$(this).removeClass("mm_cog_error");
	});

	$("#mm_personal_save").click(function() {
		var userBirth = (new Date($("#mm_nodi_birthday").val())).getTime();
		var now = (new Date()).getTime();
		var sex;
		if($("#mm_modi_sex").val() == "女") {
			sex = 0;
		} else {
			sex = 1;
		}
		if (userBirth > now) {
			M.alert("生日日期不能超过当前日期");
			$("#mm_nodi_birthday").addClass("mm_cog_error");
		} else {
			M.ajax("/api/setting/setBasic/", {
				name: $("#mm_modi_username").val(),
				birthday: $("#mm_modi_birthday").val(),
				sex: sex,
				province: $("#mm_cog_pro").val(),
				city: $("#mm_cog_city").val(),
				college: $("#mm_modi_college").val(),
				des: $("#mm_modi_des").val()
			}, function(data) {
				if (data['code'] == 0) {
					Phenix.init({
						width: 500,
						height: 300,
						template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
						data: {
							color: "#36b14a",
							face: ":)",
							title: "恭喜您！已经修改成功！",
						}
					}).show();
					Phenix.show(function() {
						setTimeout("window.location.reload();",3000);
					});
				} else if (data['code'] == 601) {
					$("#mm_personal_tip").css("display", "block");
					$("#mm_personal_tip").html("用户名不能为空");
					$("#mm_modi_username").addClass("mm_cog_error");
				} else if (data['code'] == 105) {
					$("#mm_personal_tip").css("display", "block");
					$("#mm_personal_tip").html("用户名与已有账号重复");
					$("#mm_modi_username").addClass("mm_cog_error");
				}
			});
		}
	});
	var $mm_cog_l_list = $(".mm_cog_l_list").find('li');
	function bindEmail(){
		$mm_cog_l_list.eq($mm_cog_l_list.length-1).addClass("mm_cog_list_active").siblings().removeClass();
        $('.mm_cog_item').eq(2).addClass("mm_cog_active").siblings().removeClass("mm_cog_active");
	}
	$('#toBindEmailBtn').click(function(){
		bindEmail();
	});
	$('#toActiveBtn').click(function(){
		bindEmail();
	})
	var link = window.location.href;
	/**  REAIZE PWD  **/
	$("#mm_old_pwd").focus(function() {
		$("#mm_old_pwd").removeClass("mm_cog_error");
	});
	$("#mm_new_pwd_unth").focus(function() {
		$("#mm_new_pwd_unth").removeClass("mm_cog_error");
	});
	$("#mm_renew_pwd_unth").focus(function() {
		$("#mm_renew_pwd_unth").removeClass("mm_cog_error");
	});
	var phone_num = $("#phone_num_input").val();
	if(phone_num && phone_num.length!= 1){
		$("#phone_num").html($("#phone_num_input").val().substring(0,3)+"****"+$("#phone_num_input").val().substring(7,11));
	}
	
	$("#mm_pwd_save").click(function() {
		if ($("#mm_old_pwd").val() == "") {
			$("#mm_pwd_tip").css("display", "block");
			$("#mm_pwd_tip").html("原密码不为空");
			$("#mm_old_pwd").addClass("mm_cog_error");
		} else if ($("#mm_new_pwd_unth").val().length < 6 || (!$("#mm_new_pwd_unth").val().match(/[A-Za-z]+/))) {
			$("#mm_pwd_tip").css("display", "block");
			$("#mm_pwd_tip").html("新密码格式不正确");
			$("#mm_new_pwd_unth").val("");
			$("#mm_new_pwd_unth").addClass("mm_cog_error");
		} else if ($("#mm_renew_pwd_unth").val() != $("#mm_new_pwd_unth").val()) {
			$("#mm_pwd_tip").css("display", "block");
			$("#mm_pwd_tip").html("两次输入的密码不一致");
			$("#mm_new_pwd_unth").val("");
			$("#mm_renew_pwd_unth").val("");
			$("#mm_new_pwd_unth").addClass("mm_cog_error");
			$("#mm_renew_pwd_unth").addClass("mm_cog_error");
		} else {
			M.ajax("/api/setting/setPwd/", {
				password: M.crypto.md5($("#mm_old_pwd").val()),
				newkey: M.crypto.md5($("#mm_new_pwd_unth").val()),
				renewkey: M.crypto.md5($("#mm_renew_pwd_unth").val())
			}, function(data) {
				if (data['code'] == 1) {
					Phenix.init({
						width: 500,
						height: 400,
						template: '<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div><div class=\"mm_temp_des\">{{description}}<br />如无法跳转，请点击<a href="http://passport.mengma.com/logout/">这里</a></div>',
						data: {
							color: "#36b14a",
							face: ":)",
							title: "恭喜您！密码已经修改成功！",
							description: "您需要重新登陆，<span id=\"mm_temp_timer\">"+ _i +"</span> 秒后将跳转至登录页面。",
						}
					}).show();
					Phenix.show(function(e) {
						timer();
					});
				} else if (data['code'] == 103) {
					$("#mm_pwd_tip").css("display", "block");
					$("#mm_pwd_tip").html("密码不正确");
					$("#mm_old_pwd").val("");
					$("#mm_new_pwd_unth").val("");
					$("#mm_renew_pwd_unth").val("");
					$("#mm_old_pwd").addClass("mm_cog_error");
				} else {
					Phenix.init({
						width: 500,
						height: 300,
						template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
						data: {
							color: "#b9b9bd",
							face: ":(",
							title: "异常错误！",
						}
					}).show();
					Phenix.show(function() {
						setTimeout("Phenix.hide();",3000);
					});
				}
			});
		}
	});

	/**  THIRD LAND SET PWD  **/
	$("#mm_new_pwd_th").focus(function() {
		$("#mm_new_pwd_th").removeClass("mm_cog_error");
		$('#mm_thpwd_tip').html('');
	});
	$("#mm_renew_pwd_th").focus(function() {
		$("#mm_renew_pwd_th").removeClass("mm_cog_error");
		$('#mm_repwd_tip').html('');
	});
	
	$("#mm_thpwd_save").click(function() {
		if($("#mm_new_pwd_th").val()==""){
			$("#mm_new_pwd_th").addClass('mm_cog_error');
			$("#mm_thpwd_tip").html("新密码不能为空");
		}else if($("#mm_renew_pwd_th").val()==""){
			$("#mm_renew_pwd_th").addClass('mm_cog_error');
		}else{
			if($("#mm_new_pwd_th").val()){
				if ($("#mm_new_pwd_th").val().length < 6 || (!$("#mm_new_pwd_th").val().match(/[A-Za-z]+/))) {
					$("#mm_thpwd_tip").html("新密码格式不正确");
					$("#mm_new_pwd_th").addClass("mm_cog_error");
				} else if ($("#mm_new_pwd_th").val() && $("#mm_renew_pwd_th").val()) {
					if($("#mm_renew_pwd_th").val() != $("#mm_new_pwd_th").val()){
						$("#mm_repwd_tip").html("两次输入的密码不一致");
						$("#mm_renew_pwd_th").addClass("mm_cog_error");
					}else{
						$("#mm_new_pwd_th").removeClass("mm_cog_error");
						$("#mm_renew_pwd_th").removeClass("mm_cog_error");
						$.ajax({
							url: "/api/setting/setThirdPwd/",
							type: "POST",
							data: {
								newkey: M.crypto.md5($("#mm_new_pwd_th").val()),
								renewkey: M.crypto.md5($("#mm_renew_pwd_th").val()),
							},
							success: function(data) {
								if (data['success'] == 1) {
									Phenix.init({
										width: 500,
										height: 300,
										template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
										data: {
											color: "#36b14a",
											face: ":)",
											title: "恭喜您！密码设置成功！",
										}
									}).show();
									Phenix.show(function() {
										setTimeout("window.location.href='http://www.mengma.com'",5000);
									});
								} else {
									Phenix.init({
										width: 500,
										height: 300,
										template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
										data: {
											color: "#b9b9bd",
											face: ":(",
											title: "异常错误！",
										}
									}).show();
									Phenix.show(function() {
										setTimeout("Phenix.hide();",5000);
									});
								}
							}
						});
					}
				} 
			}
		}

		
	});
	$("#mm_cog_mail_bind").focus(function() {
		$("#mm_email_tip").html("");
		$("#mm_cog_mail_bind").removeClass("mm_cog_error");
	});
	$('#mm_my_email').focus(function(){
		$(this).removeClass('mm_cog_error');
		$("#mm_email_tip").html("");
	});
	$("#mm_go_binding").click(function() {
		setEmail($('#mm_cog_mail_bind'));
	});
	function VerifyEmail(){
		$.ajax({
			url: "/api/setting/sendVerifyEmail",
			type: "POST",
			success: function(data) {
				if (data['code'] == "0") {
					$('#mm_cog_email_unbinding').hide();
					$('#mm_cog_email_unverify').hide();
					$('#mm_email_verfing').show();
					$('#stepRound').find('li').eq(0).find('a').html("邮件已发送");
					$('#stepRound').find('li').eq(1).addClass('active');
				} else if (data['code'] == "403") {
					Phenix.init({
						width: 500,
						height: 300,
						template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
						data: {
							color: "#b9b9bd",
							face: ":(",
							title: "操作过于频繁，请稍后再试！",
						}
					}).show();
					Phenix.show(function() {
						setTimeout("Phenix.hide();",5000);
					});
				} else {
					Phenix.init({
						width: 500,
						height: 300,
						template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
						data: {
							color: "#b9b9bd",
							face: ":(",
							title: "异常错误！",
						}
					}).show();
					Phenix.show(function() {
						setTimeout("Phenix.hide();",5000);
					});
				}
			}
		});
	}
	function setEmail($input){
		if ($input.val() == "") {
			$(".mm_email_tip").html("邮箱不能为空");
			$input.addClass("mm_cog_error");
		} else if (!$input.val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) {
			$(".mm_email_tip").html("邮箱格式不正确");
			$input.addClass("mm_cog_error");
		} else {
			$.ajax({
				url: "/api/setting/saveEmail/",
				type: "POST",
				data: {
					email: $input.val(),
				},
				success: function(data) {
					$('#cur_email').html($input.val())
					$(".mm_email_tip").html("");
					if (data['code'] == "0") {
						$("#mm_email_tip").css("display", "none");
						VerifyEmail();
						$('#stepRound').find('li').eq(1).addClass('active');
					} else if (data['code'] == "403") {
						Phenix.init({
							width: 500,
							height: 300,
							template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
							data: {
								color: "#b9b9bd",
								face: ":(",
								title: "操作过于频繁，请稍后再试！",
							}
						}).show();
						Phenix.show(function() {
							setTimeout("Phenix.hide();",5000);
						});
					} else if (data['code'] == "408") {
						Phenix.init({
							width: 500,
							height: 300,
							template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
							data: {
								color: "#b9b9bd",
								face: ":(",
								title: "该邮箱已绑定其他账号！",
							}
						}).show();
						Phenix.show(function() {
							setTimeout("Phenix.hide();",5000);
						});
					} else {
						Phenix.init({
							width: 500,
							height: 300,
							template: "<div style=\"color:{{color}};\" class=\"mm_temp_face\">{{face}}</div><div class=\"mm_temp_title\">{{title}}</div>",
							data: {
								color: "#b9b9bd",
								face: ":(",
								title: "异常错误！",
							}
						}).show();
						Phenix.show(function() {
							setTimeout("Phenix.hide();",5000);
						});
					}
				}
			});
		}
	}
	/*resend_Email*/
	$('#mm_resend_email').click(function(){
		$("#mm_send_email").click();
	});
	/*send_Email*/
	$("#mm_send_email").click(function(){
		setEmail($('#mm_my_email'));
	})
	$("#mm_cog_gomail_1").click(function() {
		var links = $("#cur_email").html().split("@")[1];
		window.open("http://mail." + links);
	});
	$("#mm_cog_gobinding").click(function() {
		$(".mm_cog_l_list").find("li").eq(2).click();
	});
	$("#mm_modi_birthday").datetimepicker({
		format: "yyyy-mm-dd",
		autoclose: true,
		minView: "month"
	});
	try {
		var sf = new Array();
		sf[0] = new Array("北京市", "东城|西城|崇文|宣武|朝阳|丰台|石景山|海淀|门头沟|房山|通州|顺义|昌平|大兴|平谷|怀柔|密云|延庆");
		sf[1] = new Array("上海市", "黄浦|卢湾|徐汇|长宁|静安|普陀|闸北|虹口|杨浦|闵行|宝山|嘉定|浦东|金山|松江|青浦|南汇|奉贤|崇明");
		sf[2] = new Array("天津市", "和平|东丽|河东|西青|河西|津南|南开|北辰|河北|武清|红挢|塘沽|汉沽|大港|宁河|静海|宝坻|蓟县");
		sf[3] = new Array("重庆市", "万州|涪陵|渝中|大渡口|江北|沙坪坝|九龙坡|南岸|北碚|万盛|双挢|渝北|巴南|黔江|长寿|綦江|潼南|铜梁 |大足|荣昌|壁山|梁平|城口|丰都|垫江|武隆|忠县|开县|云阳|奉节|巫山|巫溪|石柱|秀山|酉阳|彭水|江津|合川|永川|南川");
		sf[4] = new Array("河北省", "石家庄|邯郸|邢台|保定|张家口|承德|廊坊|唐山|秦皇岛|沧州|衡水");
		sf[5] = new Array("山西省", "太原|大同|阳泉|长治|晋城|朔州|吕梁|忻州|晋中|临汾|运城");
		sf[6] = new Array("内蒙古自治区", "呼和浩特|包头|乌海|赤峰|呼伦贝尔盟|阿拉善盟|哲里木盟|兴安盟|乌兰察布盟|锡林郭勒盟|巴彦淖尔盟|伊克昭盟");
		sf[7] = new Array("辽宁省", "沈阳|大连|鞍山|抚顺|本溪|丹东|锦州|营口|阜新|辽阳|盘锦|铁岭|朝阳|葫芦岛");
		sf[8] = new Array("吉林省", "长春|吉林|四平|辽源|通化|白山|松原|白城|延边");
		sf[9] = new Array("黑龙江省", "哈尔滨|齐齐哈尔|牡丹江|佳木斯|大庆|绥化|鹤岗|鸡西|黑河|双鸭山|伊春|七台河|大兴安岭");
		sf[10] = new Array("江苏省", "南京|镇江|苏州|南通|扬州|盐城|徐州|连云港|常州|无锡|宿迁|泰州|淮安");
		sf[11] = new Array("浙江省", "杭州|宁波|温州|嘉兴|湖州|绍兴|金华|衢州|舟山|台州|丽水");
		sf[12] = new Array("安徽省", "合肥|芜湖|蚌埠|马鞍山|淮北|铜陵|安庆|黄山|滁州|宿州|池州|淮南|巢湖|阜阳|六安|宣城|亳州");
		sf[13] = new Array("福建省", "福州|厦门|莆田|三明|泉州|漳州|南平|龙岩|宁德");
		sf[14] = new Array("江西省", "南昌市|景德镇|九江|鹰潭|萍乡|新馀|赣州|吉安|宜春|抚州|上饶");
		sf[15] = new Array("山东省", "济南|青岛|淄博|枣庄|东营|烟台|潍坊|济宁|泰安|威海|日照|莱芜|临沂|德州|聊城|滨州|菏泽");
		sf[16] = new Array("河南省", "郑州|开封|洛阳|平顶山|安阳|鹤壁|新乡|焦作|濮阳|许昌|漯河|三门峡|南阳|商丘|信阳|周口|驻马店|济源");
		sf[17] = new Array("湖北省", "武汉|宜昌|荆州|襄樊|黄石|荆门|黄冈|十堰|恩施|潜江|天门|仙桃|随州|咸宁|孝感|鄂州");
		sf[18] = new Array("湖南省", "长沙|常德|株洲|湘潭|衡阳|岳阳|邵阳|益阳|娄底|怀化|郴州|永州|湘西|张家界");
		sf[19] = new Array("广东省", "广州|深圳|珠海|汕头|东莞|中山|佛山|韶关|江门|湛江|茂名|肇庆|惠州|梅州|汕尾|河源|阳江|清远|潮州|揭阳|云浮");
		sf[20] = new Array("广西壮族自治区", "南宁|柳州|桂林|梧州|北海|防城港|钦州|贵港|玉林|南宁地区|柳州地区|贺州|百色|河池");
		sf[21] = new Array("海南省", "海口|三亚");
		sf[22] = new Array("四川省", "成都|绵阳|德阳|自贡|攀枝花|广元|内江|乐山|南充|宜宾|广安|达川|雅安|眉山|甘孜|凉山|泸州");
		sf[23] = new Array("贵州省", "贵阳|六盘水|遵义|安顺|铜仁|黔西南|毕节|黔东南|黔南");
		sf[24] = new Array("云南省", "昆明|大理|曲靖|玉溪|昭通|楚雄|红河|文山|思茅|西双版纳|保山|德宏|丽江|怒江|迪庆|临沧");
		sf[25] = new Array("西藏自治区", "拉萨|日喀则|山南|林芝|昌都|阿里|那曲");
		sf[26] = new Array("陕西省", "西安|宝鸡|咸阳|铜川|渭南|延安|榆林|汉中|安康|商洛");
		sf[27] = new Array("甘肃省", "兰州|嘉峪关|金昌|白银|天水|酒泉|张掖|武威|定西|陇南|平凉|庆阳|临夏|甘南");
		sf[28] = new Array("宁夏回族自治区", "银川|石嘴山|吴忠|固原");
		sf[29] = new Array("青海省", "西宁|海东|海南|海北|黄南|玉树|果洛|海西");
		sf[30] = new Array("新疆维吾尔族自治区", "乌鲁木齐|石河子|克拉玛依|伊犁|巴音郭勒|昌吉|克孜勒苏柯尔克孜|博尔塔拉|吐鲁番|哈密|喀什|和田|阿克苏");
		sf[31] = new Array("香港特别行政区", "香港特别行政区");
		sf[32] = new Array("澳门特别行政区", "澳门特别行政区");
		sf[33] = new Array("台湾省", "台北|高雄|台中|台南|屏东|南投|云林|新竹|彰化|苗栗|嘉义|花莲|桃园|宜兰|基隆|台东|金门|马祖|澎湖");
		sf[34] = new Array("其它", "北美洲|南美洲|亚洲|非洲|欧洲|大洋洲");
	} catch (e) {
		alert(e);
	}
	$("#mm_cog_pro").change(function() {
		try {
			var pro = $(this).val();
			var i, j, tmpcity = new Array();
			for (i = 0; i < sf.length; i++) {
				if (pro == sf[i][0].toString()) {
					tmpcity = sf[i][1].split("|");
					$("#mm_cog_city").html("");
					for (j = 0; j < tmpcity.length; j++) {
						$("#mm_cog_city").append("<option>" + tmpcity[j] + "</option>");
					}
				}
			}
		} catch (e) {
			alert(e);
		}
	});
	if($("#mm_cog_pro").data("p") != "") {
		$("#mm_cog_pro").val($("#mm_cog_pro").data("p"));
		try {
			var pro = $("#mm_cog_pro").data("p");
			var i, j, tmpcity = new Array();
			for (i = 0; i < sf.length; i++) {
				if (pro == sf[i][0].toString()) {
					tmpcity = sf[i][1].split("|");
					$("#mm_cog_city").html("");
					for (j = 0; j < tmpcity.length; j++) {
						$("#mm_cog_city").append("<option>" + tmpcity[j] + "</option>");
					}
					$("#mm_cog_city").val($("#mm_cog_pro").data("city"));
				}
			}
		} catch (e) {
			alert(e);
		}
	}
});

(function(f) {
	function s() {
		return new Date(Date.UTC.apply(Date, arguments));
	}
	var p = function(a, c) {
		var b = this;
		this.element = f(a);
		this.language = c.language || this.element.data("date-language") || "en";
		this.language = this.language in h ? this.language : "en";
		this.isRTL = h[this.language].rtl || !1;
		this.formatType = c.formatType || this.element.data("format-type") || "standard";
		this.format = e.parseFormat(c.format || this.element.data("date-format") || e.getDefaultFormat(this.formatType, "input"), this.formatType);
		this.isVisible = this.isInline = !1;
		this.isInput = this.element.is("input");
		this.component = this.element.is(".date") ? this.element.find(".add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar").parent() : !1;
		this.componentReset = this.element.is(".date") ? this.element.find(".add-on .icon-remove").parent() : !1;
		this.hasInput = this.component && this.element.find("input").length;
		this.component && 0 === this.component.length && (this.component = !1);
		this.linkField = c.linkField || this.element.data("link-field") || !1;
		this.linkFormat = e.parseFormat(c.linkFormat || this.element.data("link-format") || e.getDefaultFormat(this.formatType, "link"), this.formatType);
		this.minuteStep = c.minuteStep || this.element.data("minute-step") || 5;
		this.pickerPosition = c.pickerPosition || this.element.data("picker-position") || "bottom-right";
		this.showMeridian = c.showMeridian || this.element.data("show-meridian") || !1;
		this.initialDate = c.initialDate || new Date;
		this._attachEvents();
		this.minView = 0;
		"minView" in c ? this.minView = c.minView : "minView" in this.element.data() && (this.minView = this.element.data("min-view"));
		this.minView = e.convertViewMode(this.minView);
		this.maxView = e.modes.length - 1;
		"maxView" in c ? this.maxView = c.maxView : "maxView" in this.element.data() && (this.maxView = this.element.data("max-view"));
		this.maxView = e.convertViewMode(this.maxView);
		this.startViewMode = 2;
		"startView" in c ? this.startViewMode = c.startView : "startView" in this.element.data() && (this.startViewMode = this.element.data("start-view"));
		this.viewMode = this.startViewMode = e.convertViewMode(this.startViewMode);
		this.viewSelect = this.minView;
		"viewSelect" in c ? this.viewSelect = c.viewSelect : "viewSelect" in this.element.data() && (this.viewSelect = this.element.data("view-select"));
		this.viewSelect = e.convertViewMode(this.viewSelect);
		this.forceParse = !0;
		"forceParse" in c ? this.forceParse = c.forceParse : "dateForceParse" in this.element.data() && (this.forceParse = this.element.data("date-force-parse"));
		this.picker = f(e.template).appendTo(this.isInline ? this.element : "body").on({
			click: f.proxy(this.click, this),
			mousedown: f.proxy(this.mousedown, this)
		});
		this.isInline ? this.picker.addClass("datetimepicker-inline") : this.component && "bottom-left" == this.pickerPosition ? this.picker.addClass("datetimepicker-dropdown-left dropdown-menu") : this.picker.addClass("datetimepicker-dropdown dropdown-menu");
		this.isRTL && (this.picker.addClass("datetimepicker-rtl"), this.picker.find(".prev i, .next i").toggleClass("fa fa-angle-double-left fa-angle-double-left"));
		f(document).on("mousedown", function(a) {
			0 === f(a.target).closest(".datetimepicker").length && b.hide();
		});
		this.autoclose = !1;
		"autoclose" in c ? this.autoclose = c.autoclose : "dateAutoclose" in this.element.data() && (this.autoclose = this.element.data("date-autoclose"));
		this.keyboardNavigation = !0;
		"keyboardNavigation" in c ? this.keyboardNavigation = c.keyboardNavigation : "dateKeyboardNavigation" in this.element.data() && (this.keyboardNavigation = this.element.data("date-keyboard-navigation"));
		this.todayBtn = c.todayBtn || this.element.data("date-today-btn") || !1;
		this.todayHighlight = c.todayHighlight || this.element.data("date-today-highlight") || !1;
		this.weekStart = (c.weekStart || this.element.data("date-weekstart") || h[this.language].weekStart || 0) % 7;
		this.weekEnd = (this.weekStart + 6) % 7;
		this.startDate = -Infinity;
		this.endDate = Infinity;
		this.daysOfWeekDisabled = [];
		this.setStartDate(c.startDate || this.element.data("date-startdate"));
		this.setEndDate(c.endDate || this.element.data("date-enddate"));
		this.setDaysOfWeekDisabled(c.daysOfWeekDisabled || this.element.data("date-days-of-week-disabled"));
		this.fillDow();
		this.fillMonths();
		this.update();
		this.showMode();
		this.isInline && this.show();
	};
	p.prototype = {
		constructor: p,
		_events: [],
		_attachEvents: function() {
			this._detachEvents();
			this.isInput ? this._events = [
					[this.element, {
						focus: f.proxy(this.show, this),
						keyup: f.proxy(this.update, this),
						keydown: f.proxy(this.keydown, this)
					}]
				] : this.component && this.hasInput ? (this._events = [
					[this.element.find("input"), {
						focus: f.proxy(this.show, this),
						keyup: f.proxy(this.update, this),
						keydown: f.proxy(this.keydown, this)
					}],
					[this.component, {
						click: f.proxy(this.show, this)
					}]
				], this.componentReset && this._events.push([this.componentReset, {
					click: f.proxy(this.reset, this)
				}])) : this.element.is("div") ?
				this.isInline = !0 : this._events = [
					[this.element, {
						click: f.proxy(this.show, this)
					}]
				];
			for (var a = 0, c, b; a < this._events.length; a++) {
				c = this._events[a][0], b = this._events[a][1], c.on(b);
			}
		},
		_detachEvents: function() {
			for (var a = 0, c, b; a < this._events.length; a++) {
				c = this._events[a][0], b = this._events[a][1], c.off(b);
			}
			this._events = [];
		},
		show: function(a) {
			this.picker.show();
			this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
			this.forceParse && this.update();
			this.place();
			f(window).on("resize", f.proxy(this.place, this));
			a && (a.stopPropagation(), a.preventDefault());
			this.isVisible = !0;
			this.element.trigger({
				type: "show",
				date: this.date
			});
		},
		hide: function(a) {
			this.isVisible && !this.isInline && (this.picker.hide(), f(window).off("resize", this.place), this.viewMode = this.startViewMode, this.showMode(), this.isInput || f(document).off("mousedown", this.hide), this.forceParse && (this.isInput && this.element.val() || this.hasInput && this.element.find("input").val()) && this.setValue(), this.isVisible = !1, this.element.trigger({
				type: "hide",
				date: this.date
			}));
		},
		remove: function() {
			this._detachEvents();
			this.picker.remove();
			delete this.element.data().datetimepicker;
		},
		getDate: function() {
			var a = this.getUTCDate();
			return new Date(a.getTime() + 6E4 * a.getTimezoneOffset());
		},
		getUTCDate: function() {
			return this.date;
		},
		setDate: function(a) {
			this.setUTCDate(new Date(a.getTime() - 6E4 * a.getTimezoneOffset()));
		},
		setUTCDate: function(a) {
			a >= this.startDate && a <= this.endDate ? (this.date = a, this.setValue(), this.viewDate = this.date, this.fill()) : this.element.trigger({
				type: "outOfRange",
				date: a,
				startDate: this.startDate,
				endDate: this.endDate
			});
		},
		setValue: function() {
			var a = this.getFormattedDate();
			this.isInput ? this.element.prop("value", a) : (this.component && this.element.find("input").prop("value", a), this.element.data("date", a));
			this.linkField && f("#" + this.linkField).val(this.getFormattedDate(this.linkFormat));
		},
		getFormattedDate: function(a) {
			return void 0 == a && (a = this.format), e.formatDate(this.date, a, this.language, this.formatType);
		},
		setStartDate: function(a) {
			this.startDate = a || -Infinity; - Infinity !== this.startDate && (this.startDate = e.parseDate(this.startDate, this.format, this.language, this.formatType));
			this.update();
			this.updateNavArrows();
		},
		setEndDate: function(a) {
			this.endDate = a || Infinity;
			Infinity !== this.endDate && (this.endDate = e.parseDate(this.endDate, this.format, this.language, this.formatType));
			this.update();
			this.updateNavArrows();
		},
		setDaysOfWeekDisabled: function(a) {
			this.daysOfWeekDisabled = a || [];
			f.isArray(this.daysOfWeekDisabled) || (this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/));
			this.daysOfWeekDisabled = f.map(this.daysOfWeekDisabled, function(a) {
				return parseInt(a, 10);
			});
			this.update();
			this.updateNavArrows();
		},
		place: function() {
			if (!this.isInline) {
				var a = parseInt(this.element.parents().filter(function() {
						return "auto" != f(this).css("z-index");
					}).first().css("z-index")) + 10,
					c, b;
				this.component ? (c = this.component.offset(), b = c.left, "bottom-left" == this.pickerPosition && (b += this.component.outerWidth() - this.picker.outerWidth())) : (c = this.element.offset(), b = c.left);
				this.picker.css({
					top: c.top + this.height,
					left: b,
					zIndex: a
				});
			}
		},
		update: function() {
			var a, c = !1;
			arguments && arguments.length && ("string" == typeof arguments[0] || arguments[0] instanceof Date) ? (a = arguments[0], c = !0) : a = this.isInput ? this.element.prop("value") : this.element.data("date") || this.element.find("input").prop("value") || this.initialDate;
			a || (a = new Date, c = !1);
			this.date = e.parseDate(a, this.format, this.language, this.formatType);
			c && this.setValue();
			this.date < this.startDate ? this.viewDate = new Date(this.startDate) : this.date > this.endDate ? this.viewDate = new Date(this.endDate) : this.viewDate = new Date(this.date);
			this.fill();
		},
		fillDow: function() {
			for (var a = this.weekStart, c = "<tr>"; a < this.weekStart + 7;) {
				c += '<th class="dow">' + h[this.language].daysMin[a++ % 7] + "</th>";
			}
			c += "</tr>";
			this.picker.find(".datetimepicker-days thead").append(c);
		},
		fillMonths: function() {
			for (var a = "", c = 0; 12 > c;) {
				a += '<span class="month">' + h[this.language].monthsShort[c++] + "</span>";
			}
			this.picker.find(".datetimepicker-months td").html(a);
		},
		fill: function() {
			if (null != this.date && null != this.viewDate) {
				var a = new Date(this.viewDate),
					c = a.getUTCFullYear(),
					b = a.getUTCMonth(),
					d = a.getUTCDate(),
					g = a.getUTCHours(),
					u = a.getUTCMinutes(),
					a = -Infinity !== this.startDate ? this.startDate.getUTCFullYear() : -Infinity,
					v = -Infinity !== this.startDate ? this.startDate.getUTCMonth() : -Infinity,
					w = Infinity !== this.endDate ? this.endDate.getUTCFullYear() : Infinity,
					t = Infinity !== this.endDate ? this.endDate.getUTCMonth() : Infinity,
					k = (new s(this.date.getUTCFullYear(), this.date.getUTCMonth(),
						this.date.getUTCDate())).valueOf(),
					q = new Date;
				this.picker.find(".datetimepicker-days thead th:eq(1)").text(h[this.language].months[b] + " " + c);
				this.picker.find(".datetimepicker-hours thead th:eq(1)").text(d + " " + h[this.language].months[b] + " " + c);
				this.picker.find(".datetimepicker-minutes thead th:eq(1)").text(d + " " + h[this.language].months[b] + " " + c);
				this.picker.find("tfoot th.today").text(h[this.language].today).toggle(!1 !== this.todayBtn);
				this.updateNavArrows();
				this.fillMonths();
				var l = s(c, b - 1, 28, 0, 0, 0, 0),
					n = e.getDaysInMonth(l.getUTCFullYear(), l.getUTCMonth());
				l.setUTCDate(n);
				l.setUTCDate(n - (l.getUTCDay() - this.weekStart + 7) % 7);
				var r = new Date(l);
				r.setUTCDate(r.getUTCDate() + 42);
				for (var r = r.valueOf(), n = [], m; l.valueOf() < r;) {
					l.getUTCDay() == this.weekStart && n.push("<tr>");
					m = "";
					if (l.getUTCFullYear() < c || l.getUTCFullYear() == c && l.getUTCMonth() < b) {
						m += " old";
					} else {
						if (l.getUTCFullYear() > c || l.getUTCFullYear() == c && l.getUTCMonth() > b) {
							m += " new";
						}
					}
					this.todayHighlight && l.getUTCFullYear() == q.getFullYear() && l.getUTCMonth() == q.getMonth() && l.getUTCDate() == q.getDate() && (m += " today");
					l.valueOf() == k && (m += " active");
					if (l.valueOf() + 864E5 <= this.startDate || l.valueOf() > this.endDate || -1 !== f.inArray(l.getUTCDay(), this.daysOfWeekDisabled)) {
						m += " disabled";
					}
					n.push('<td class="day' + m + '">' + l.getUTCDate() + "</td>");
					l.getUTCDay() == this.weekEnd && n.push("</tr>");
					l.setUTCDate(l.getUTCDate() + 1);
				}
				this.picker.find(".datetimepicker-days tbody").empty().append(n.join(""));
				n = [];
				r = l = q = "";
				for (k = 0; 24 > k; k++) {
					var p = s(c, b, d, k);
					m = "";
					p.valueOf() + 36E5 <= this.startDate || p.valueOf() > this.endDate ? m += " disabled" : g == k && (m += " active");
					this.showMeridian && 2 == h[this.language].meridiem.length ? (l = 12 > k ? h[this.language].meridiem[0] : h[this.language].meridiem[1], l != r && ("" != r && n.push("</fieldset>"), n.push('<fieldset class="hour"><legend>' + l.toUpperCase() + "</legend>")), r = l, q = k % 12 ? k % 12 : 12, n.push('<span class="hour' + m + " hour_" + (12 > k ? "am" : "pm") + '">' + q + "</span>"), 23 == k && n.push("</fieldset>")) : (q = k + ":00", n.push('<span class="hour' + m + '">' + q + "</span>"));
				}
				this.picker.find(".datetimepicker-hours td").html(n.join(""));
				n = [];
				r = l = q = "";
				for (k = 0; 60 > k; k += this.minuteStep) {
					p = s(c, b, d, g, k, 0), m = "", p.valueOf() < this.startDate || p.valueOf() > this.endDate ? m += " disabled" : Math.floor(u / this.minuteStep) == Math.floor(k / this.minuteStep) && (m += " active"), this.showMeridian && 2 == h[this.language].meridiem.length ? (l = 12 > g ? h[this.language].meridiem[0] : h[this.language].meridiem[1], l != r && ("" != r && n.push("</fieldset>"), n.push('<fieldset class="minute"><legend>' + l.toUpperCase() + "</legend>")), r = l, q = g % 12 ? g % 12 : 12,
						n.push('<span class="minute' + m + '">' + q + ":" + (10 > k ? "0" + k : k) + "</span>"), 59 == k && n.push("</fieldset>")) : (q = k + ":00", n.push('<span class="minute' + m + '">' + g + ":" + (10 > k ? "0" + k : k) + "</span>"));
				}
				this.picker.find(".datetimepicker-minutes td").html(n.join(""));
				b = this.date.getUTCFullYear();
				d = this.picker.find(".datetimepicker-months").find("th:eq(1)").text(c).end().find("span").removeClass("active");
				b == c && d.eq(this.date.getUTCMonth()).addClass("active");
				(c < a || c > w) && d.addClass("disabled");
				c == a && d.slice(0, v).addClass("disabled");
				c == w && d.slice(t + 1).addClass("disabled");
				n = "";
				c = 10 * parseInt(c / 10, 10);
				v = this.picker.find(".datetimepicker-years").find("th:eq(1)").text(c + "-" + (c + 9)).end().find("td");
				--c;
				for (k = -1; 11 > k; k++) {
					n += '<span class="year' + (-1 == k || 10 == k ? " old" : "") + (b == c ? " active" : "") + (c < a || c > w ? " disabled" : "") + '">' + c + "</span>", c += 1;
				}
				v.html(n);
			}
		},
		updateNavArrows: function() {
			var a = new Date(this.viewDate),
				c = a.getUTCFullYear(),
				b = a.getUTCMonth(),
				d = a.getUTCDate(),
				a = a.getUTCHours();
			switch (this.viewMode) {
				case 0:
					-Infinity !== this.startDate && c <= this.startDate.getUTCFullYear() && b <= this.startDate.getUTCMonth() && d <= this.startDate.getUTCDate() && a <= this.startDate.getUTCHours() ? this.picker.find(".prev").css({
						visibility: "hidden"
					}) : this.picker.find(".prev").css({
						visibility: "visible"
					});
					Infinity !== this.endDate && c >= this.endDate.getUTCFullYear() && b >= this.endDate.getUTCMonth() && d >= this.endDate.getUTCDate() && a >= this.endDate.getUTCHours() ? this.picker.find(".next").css({
						visibility: "hidden"
					}) : this.picker.find(".next").css({
						visibility: "visible"
					});
					break;
				case 1:
					-Infinity !== this.startDate && c <= this.startDate.getUTCFullYear() && b <= this.startDate.getUTCMonth() && d <= this.startDate.getUTCDate() ? this.picker.find(".prev").css({
						visibility: "hidden"
					}) : this.picker.find(".prev").css({
						visibility: "visible"
					});
					Infinity !== this.endDate && c >= this.endDate.getUTCFullYear() && b >= this.endDate.getUTCMonth() && d >= this.endDate.getUTCDate() ? this.picker.find(".next").css({
						visibility: "hidden"
					}) : this.picker.find(".next").css({
						visibility: "visible"
					});
					break;
				case 2:
					-Infinity !== this.startDate && c <= this.startDate.getUTCFullYear() && b <= this.startDate.getUTCMonth() ? this.picker.find(".prev").css({
						visibility: "hidden"
					}) : this.picker.find(".prev").css({
						visibility: "visible"
					});
					Infinity !== this.endDate && c >= this.endDate.getUTCFullYear() && b >= this.endDate.getUTCMonth() ? this.picker.find(".next").css({
						visibility: "hidden"
					}) : this.picker.find(".next").css({
						visibility: "visible"
					});
					break;
				case 3:
					;
				case 4:
					-Infinity !== this.startDate && c <= this.startDate.getUTCFullYear() ? this.picker.find(".prev").css({
						visibility: "hidden"
					}) : this.picker.find(".prev").css({
						visibility: "visible"
					}), Infinity !== this.endDate && c >= this.endDate.getUTCFullYear() ? this.picker.find(".next").css({
						visibility: "hidden"
					}) : this.picker.find(".next").css({
						visibility: "visible"
					});
			}
		},
		click: function(a) {
			a.stopPropagation();
			a.preventDefault();
			a = f(a.target).closest("span, td, th, legend");
			if (1 == a.length) {
				if (a.is(".disabled")) {
					this.element.trigger({
						type: "outOfRange",
						date: this.viewDate,
						startDate: this.startDate,
						endDate: this.endDate
					});
				} else {
					switch (a[0].nodeName.toLowerCase()) {
						case "th":
							switch (a[0].className) {
								case "switch":
									this.showMode(1);
									break;
								case "prev":
									;
								case "next":
									a = e.modes[this.viewMode].navStep * ("prev" == a[0].className ? -1 : 1);
									switch (this.viewMode) {
										case 0:
											this.viewDate = this.moveHour(this.viewDate, a);
											break;
										case 1:
											this.viewDate = this.moveDate(this.viewDate, a);
											break;
										case 2:
											this.viewDate = this.moveMonth(this.viewDate, a);
											break;
										case 3:
											;
										case 4:
											this.viewDate = this.moveYear(this.viewDate, a);
									}
									this.fill();
									break;
								case "today":
									a = new Date, a = s(a.getFullYear(), a.getMonth(), a.getDate(), a.getHours(), a.getMinutes(), a.getSeconds(), 0), this.viewMode = this.startViewMode, this.showMode(0), this._setDate(a), this.fill(), this.autoclose && this.hide();
							}
							break;
						case "span":
							if (!a.is(".disabled")) {
								var c = this.viewDate.getUTCFullYear(),
									b = this.viewDate.getUTCMonth(),
									d = this.viewDate.getUTCDate(),
									g = this.viewDate.getUTCHours(),
									u = this.viewDate.getUTCMinutes(),
									h = this.viewDate.getUTCSeconds();
								if (a.is(".month")) {
									this.viewDate.setUTCDate(1), b = a.parent().find("span").index(a), this.viewDate.setUTCMonth(b), this.element.trigger({
										type: "changeMonth",
										date: this.viewDate
									}), 3 <= this.viewSelect && this._setDate(s(c, b, d, g, u, h, 0));
								} else {
									if (a.is(".year")) {
										this.viewDate.setUTCDate(1), c = parseInt(a.text(), 10) || 0, this.viewDate.setUTCFullYear(c), this.element.trigger({
											type: "changeYear",
											date: this.viewDate
										}), 4 <= this.viewSelect && this._setDate(s(c, b, d, g, u, h, 0));
									} else {
										if (a.is(".hour")) {
											g = parseInt(a.text(), 10) || 0;
											if (a.hasClass("hour_am") || a.hasClass("hour_pm")) {
												12 == g && a.hasClass("hour_am") ? g = 0 : 12 != g && a.hasClass("hour_pm") && (g += 12);
											}
											this.viewDate.setUTCHours(g);
											this.element.trigger({
												type: "changeHour",
												date: this.viewDate
											});
											1 <= this.viewSelect && this._setDate(s(c, b, d, g, u, h, 0));
										} else {
											a.is(".minute") && (u = parseInt(a.text().substr(a.text().indexOf(":") + 1), 10) || 0, this.viewDate.setUTCMinutes(u), this.element.trigger({
												type: "changeMinute",
												date: this.viewDate
											}), 0 <= this.viewSelect && this._setDate(s(c, b, d, g, u, h, 0)));
										}
									}
								}
								0 != this.viewMode ? (a = this.viewMode, this.showMode(-1), this.fill(), a == this.viewMode && this.autoclose && this.hide()) : (this.fill(), this.autoclose && this.hide());
							}
							break;
						case "td":
							a.is(".day") && !a.is(".disabled") && (d = parseInt(a.text(), 10) || 1, c = this.viewDate.getUTCFullYear(), b = this.viewDate.getUTCMonth(), g = this.viewDate.getUTCHours(), u = this.viewDate.getUTCMinutes(), h = this.viewDate.getUTCSeconds(), a.is(".old") ? 0 === b ? (b = 11, --c) : --b : a.is(".new") && (11 == b ? (b = 0, c += 1) : b += 1), this.viewDate.setUTCDate(d), this.viewDate.setUTCMonth(b), this.viewDate.setUTCFullYear(c), this.element.trigger({
									type: "changeDay",
									date: this.viewDate
								}),
								2 <= this.viewSelect && this._setDate(s(c, b, d, g, u, h, 0))), a = this.viewMode, this.showMode(-1), this.fill(), a == this.viewMode && this.autoclose && this.hide();
					}
				}
			}
		},
		_setDate: function(a, c) {
			c && "date" != c || (this.date = a);
			c && "view" != c || (this.viewDate = a);
			this.fill();
			this.element.trigger({
				type: "changeDate",
				date: this.date
			});
			this.setValue();
			var b;
			this.isInput ? b = this.element : this.component && (b = this.element.find("input"));
			b && (b.change(), this.autoclose && (!c || "date" == c));
		},
		moveMinute: function(a, c) {
			if (!c) {
				return a;
			}
			var b = new Date(a.valueOf());
			return b.setUTCMinutes(b.getUTCMinutes() + c * this.minuteStep), b;
		},
		moveHour: function(a, c) {
			if (!c) {
				return a;
			}
			var b = new Date(a.valueOf());
			return b.setUTCHours(b.getUTCHours() + c), b;
		},
		moveDate: function(a, c) {
			if (!c) {
				return a;
			}
			var b = new Date(a.valueOf());
			return b.setUTCDate(b.getUTCDate() + c), b;
		},
		moveMonth: function(a, c) {
			if (!c) {
				return a;
			}
			var b = new Date(a.valueOf()),
				d = b.getUTCDate(),
				g = b.getUTCMonth(),
				h = Math.abs(c),
				f;
			c = 0 < c ? 1 : -1;
			if (1 == h) {
				if (h = -1 == c ? function() {
						return b.getUTCMonth() == g;
					} : function() {
						return b.getUTCMonth() != f;
					}, f = g + c, b.setUTCMonth(f), 0 > f || 11 < f) {
					f = (f + 12) % 12;
				}
			} else {
				for (var e = 0; e < h; e++) {
					b = this.moveMonth(b, c);
				}
				f = b.getUTCMonth();
				b.setUTCDate(d);
				h = function() {
					return f != b.getUTCMonth();
				};
			}
			for (; h();) {
				b.setUTCDate(--d), b.setUTCMonth(f);
			}
			return b;
		},
		moveYear: function(a, c) {
			return this.moveMonth(a, 12 * c);
		},
		dateWithinRange: function(a) {
			return a >= this.startDate && a <= this.endDate;
		},
		keydown: function(a) {
			if (this.picker.is(":not(:visible)")) {
				27 == a.keyCode && this.show();
			} else {
				var c = !1,
					b, d, g;
				switch (a.keyCode) {
					case 27:
						this.hide();
						a.preventDefault();
						break;
					case 37:
						;
					case 39:
						if (!this.keyboardNavigation) {
							break;
						}
						b = 37 == a.keyCode ? -1 : 1;
						viewMode = this.viewMode;
						a.ctrlKey ? viewMode += 2 : a.shiftKey && (viewMode += 1);
						4 == viewMode ? (d = this.moveYear(this.date, b), g = this.moveYear(this.viewDate, b)) : 3 == viewMode ? (d = this.moveMonth(this.date, b), g = this.moveMonth(this.viewDate, b)) : 2 == viewMode ? (d = this.moveDate(this.date, b), g = this.moveDate(this.viewDate, b)) : 1 == viewMode ? (d = this.moveHour(this.date, b), g = this.moveHour(this.viewDate, b)) : 0 == viewMode && (d = this.moveMinute(this.date, b), g = this.moveMinute(this.viewDate, b));
						this.dateWithinRange(d) && (this.date = d, this.viewDate = g, this.setValue(), this.update(), a.preventDefault(), c = !0);
						break;
					case 38:
						;
					case 40:
						if (!this.keyboardNavigation) {
							break;
						}
						b = 38 == a.keyCode ? -1 : 1;
						viewMode = this.viewMode;
						a.ctrlKey ? viewMode += 2 : a.shiftKey && (viewMode += 1);
						4 == viewMode ? (d = this.moveYear(this.date, b), g = this.moveYear(this.viewDate, b)) : 3 == viewMode ? (d = this.moveMonth(this.date, b), g = this.moveMonth(this.viewDate, b)) : 2 == viewMode ? (d = this.moveDate(this.date, 7 * b), g = this.moveDate(this.viewDate, 7 * b)) : 1 == viewMode ? this.showMeridian ? (d = this.moveHour(this.date, 6 * b), g = this.moveHour(this.viewDate, 6 * b)) : (d = this.moveHour(this.date, 4 * b), g = this.moveHour(this.viewDate, 4 * b)) : 0 == viewMode &&
							(d = this.moveMinute(this.date, 4 * b), g = this.moveMinute(this.viewDate, 4 * b));
						this.dateWithinRange(d) && (this.date = d, this.viewDate = g, this.setValue(), this.update(), a.preventDefault(), c = !0);
						break;
					case 13:
						0 != this.viewMode ? (b = this.viewMode, this.showMode(-1), this.fill(), b == this.viewMode && this.autoclose && this.hide()) : (this.fill(), this.autoclose && this.hide());
						a.preventDefault();
						break;
					case 9:
						this.hide();
				}
				if (c) {
					this.element.trigger({
						type: "changeDate",
						date: this.date
					});
					var f;
					this.isInput ? f = this.element : this.component && (f = this.element.find("input"));
					f && f.change();
				}
			}
		},
		showMode: function(a) {
			a && (a = Math.max(0, Math.min(e.modes.length - 1, this.viewMode + a)), a >= this.minView && a <= this.maxView && (this.viewMode = a));
			this.picker.find(">div").hide().filter(".datetimepicker-" + e.modes[this.viewMode].clsName).css("display", "block");
			this.updateNavArrows();
		},
		reset: function(a) {
			this._setDate(null, "date");
		}
	};
	f.fn.datetimepicker = function(a) {
		var c = Array.apply(null, arguments);
		return c.shift(), this.each(function() {
			var b = f(this),
				d = b.data("datetimepicker"),
				g = "object" == typeof a && a;
			d || b.data("datetimepicker", d = new p(this, f.extend({}, f.fn.datetimepicker.defaults, g)));
			"string" == typeof a && "function" == typeof d[a] && d[a].apply(d, c);
		});
	};
	f.fn.datetimepicker.defaults = {};
	f.fn.datetimepicker.Constructor = p;
	var h = f.fn.datetimepicker.dates = {
			en: {
				days: "\u661f\u671f\u65e5 \u661f\u671f\u4e00 \u661f\u671f\u4e8c \u661f\u671f\u4e09 \u661f\u671f\u56db \u661f\u671f\u4e94 \u661f\u671f\u516d \u661f\u671f\u65e5".split(" "),
				daysShort: "\u5468\u65e5 \u5468\u4e00 \u5468\u4e8c \u5468\u4e09 \u5468\u56db \u5468\u4e94 \u5468\u516d \u5468\u65e5".split(" "),
				daysMin: "\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u65e5".split(""),
				months: "\u4e00\u6708 \u4e8c\u6708 \u4e09\u6708 \u56db\u6708 \u4e94\u6708 \u516d\u6708 \u4e03\u6708 \u516b\u6708 \u4e5d\u6708 \u5341\u6708 \u5341\u4e00\u6708 \u5341\u4e8c\u6708".split(" "),
				monthsShort: "1\u6708 2\u6708 3\u6708 4\u6708 5\u6708 6\u6708 7\u6708 8\u6708 9\u6708 10\u6708 11\u6708 12\u6708".split(" "),
				meridiem: ["am", "pm"],
				suffix: ["st", "nd", "rd", "th"],
				today: "\u4eca\u65e5"
			}
		},
		e = {
			modes: [{
				clsName: "minutes",
				navFnc: "Hours",
				navStep: 1
			}, {
				clsName: "hours",
				navFnc: "Date",
				navStep: 1
			}, {
				clsName: "days",
				navFnc: "Month",
				navStep: 1
			}, {
				clsName: "months",
				navFnc: "FullYear",
				navStep: 1
			}, {
				clsName: "years",
				navFnc: "FullYear",
				navStep: 10
			}],
			isLeapYear: function(a) {
				return 0 === a % 4 && 0 !== a % 100 || 0 === a % 400;
			},
			getDaysInMonth: function(a, c) {
				return [31, e.isLeapYear(a) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][c];
			},
			getDefaultFormat: function(a, c) {
				if ("standard" == a) {
					return "input" == c ? "yyyy-mm-dd hh:ii" : "yyyy-mm-dd hh:ii:ss";
				}
				if ("php" == a) {
					return "input" == c ? "Y-m-d H:i" : "Y-m-d H:i:s";
				}
				throw Error("Invalid format type.");
			},
			validParts: function(a) {
				if ("standard" == a) {
					return /hh?|HH?|p|P|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
				}
				if ("php" == a) {
					return /[dDjlNwzFmMnStyYaABgGhHis]/g;
				}
				throw Error("Invalid format type.");
			},
			nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
			parseFormat: function(a, c) {
				var b = a.replace(this.validParts(c), "\x00").split("\x00"),
					d = a.match(this.validParts(c));
				if (!b || !b.length || !d || 0 == d.length) {
					throw Error("Invalid date format.");
				}
				return {
					separators: b,
					parts: d
				};
			},
			parseDate: function(a, c, b, d) {
				if (a instanceof Date) {
					return a = new Date(a.valueOf() - 6E4 * a.getTimezoneOffset()), a.setMilliseconds(0), a;
				}
				/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(a) && (c = this.parseFormat("yyyy-mm-dd", d));
				/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(a) && (c = this.parseFormat("yyyy-mm-dd hh:ii", d));
				/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(a) && (c = this.parseFormat("yyyy-mm-dd hh:ii:ss", d));
				if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(a)) {
					c = /([-+]\d+)([dmwy])/;
					var g = a.match(/([-+]\d+)([dmwy])/g);
					a = new Date;
					for (var e = 0; e < g.length; e++) {
						switch (d = c.exec(g[e]), b = parseInt(d[1]), d[2]) {
							case "d":
								a.setUTCDate(a.getUTCDate() + b);
								break;
							case "m":
								a = p.prototype.moveMonth.call(p.prototype, a, b);
								break;
							case "w":
								a.setUTCDate(a.getUTCDate() + 7 * b);
								break;
							case "y":
								a = p.prototype.moveYear.call(p.prototype, a, b);
						}
					}
					return s(a.getUTCFullYear(), a.getUTCMonth(), a.getUTCDate(), a.getUTCHours(), a.getUTCMinutes(), a.getUTCSeconds(), 0);
				}
				g = a && a.match(this.nonpunctuation) || [];
				a = new Date(0, 0, 0, 0, 0, 0, 0);
				var v = {},
					w = "hh h ii i ss s yyyy yy M MM m mm D DD d dd H HH p P".split(" "),
					t = {
						hh: function(a, b) {
							return a.setUTCHours(b);
						},
						h: function(a, b) {
							return a.setUTCHours(b);
						},
						HH: function(a, b) {
							return a.setUTCHours(12 == b ? 0 : b);
						},
						H: function(a, b) {
							return a.setUTCHours(12 == b ? 0 : b);
						},
						ii: function(a, b) {
							return a.setUTCMinutes(b);
						},
						i: function(a, b) {
							return a.setUTCMinutes(b);
						},
						ss: function(a, b) {
							return a.setUTCSeconds(b);
						},
						s: function(a, b) {
							return a.setUTCSeconds(b);
						},
						yyyy: function(a, b) {
							return a.setUTCFullYear(b);
						},
						yy: function(a, b) {
							return a.setUTCFullYear(2E3 + b);
						},
						m: function(a, b) {
							for (--b; 0 > b;) {
								b += 12;
							}
							b %= 12;
							for (a.setUTCMonth(b); a.getUTCMonth() != b;) {
								a.setUTCDate(a.getUTCDate() - 1);
							}
							return a;
						},
						d: function(a, b) {
							return a.setUTCDate(b);
						},
						p: function(a, b) {
							return a.setUTCHours(1 == b ? a.getUTCHours() + 12 : a.getUTCHours());
						}
					},
					k;
				t.M = t.MM = t.mm = t.m;
				t.dd = t.d;
				t.P = t.p;
				a = s(a.getFullYear(), a.getMonth(), a.getDate(), a.getHours(), a.getMinutes(), a.getSeconds());
				if (g.length == c.parts.length) {
					for (var e = 0, q = c.parts.length; e < q; e++) {
						k = parseInt(g[e], 10);
						d = c.parts[e];
						if (isNaN(k)) {
							switch (d) {
								case "MM":
									k = f(h[b].months).filter(function() {
										var a = this.slice(0, g[e].length),
											b = g[e].slice(0, a.length);
										return a == b;
									});
									k = f.inArray(k[0], h[b].months) + 1;
									break;
								case "M":
									k = f(h[b].monthsShort).filter(function() {
										var a = this.slice(0, g[e].length),
											b = g[e].slice(0, a.length);
										return a == b;
									});
									k = f.inArray(k[0], h[b].monthsShort) + 1;
									break;
								case "p":
									;
								case "P":
									k = f.inArray(g[e].toLowerCase(), h[b].meridiem);
							}
						}
						v[d] = k;
					}
					for (e = 0; e < w.length; e++) {
						d = w[e], d in v && !isNaN(v[d]) && t[d](a, v[d]);
					}
				}
				return a;
			},
			formatDate: function(a, c, b, d) {
				if (null == a) {
					return "";
				}
				if ("standard" == d) {
					b = {
							yy: a.getUTCFullYear().toString().substring(2),
							yyyy: a.getUTCFullYear(),
							m: a.getUTCMonth() + 1,
							M: h[b].monthsShort[a.getUTCMonth()],
							MM: h[b].months[a.getUTCMonth()],
							d: a.getUTCDate(),
							D: h[b].daysShort[a.getUTCDay()],
							DD: h[b].days[a.getUTCDay()],
							p: 2 == h[b].meridiem.length ? h[b].meridiem[12 > a.getUTCHours() ? 0 : 1] : "",
							h: a.getUTCHours(),
							i: a.getUTCMinutes(),
							s: a.getUTCSeconds()
						}, b.H = 0 == b.h % 12 ? 12 : b.h % 12, b.HH = (10 > b.H ? "0" : "") + b.H, b.P = b.p.toUpperCase(), b.hh =
						(10 > b.h ? "0" : "") + b.h, b.ii = (10 > b.i ? "0" : "") + b.i, b.ss = (10 > b.s ? "0" : "") + b.s, b.dd = (10 > b.d ? "0" : "") + b.d, b.mm = (10 > b.m ? "0" : "") + b.m;
				} else {
					if ("php" != d) {
						throw Error("Invalid format type.");
					}
					b = {
						y: a.getUTCFullYear().toString().substring(2),
						Y: a.getUTCFullYear(),
						F: h[b].months[a.getUTCMonth()],
						M: h[b].monthsShort[a.getUTCMonth()],
						n: a.getUTCMonth() + 1,
						t: e.getDaysInMonth(a.getUTCFullYear(), a.getUTCMonth()),
						j: a.getUTCDate(),
						l: h[b].days[a.getUTCDay()],
						D: h[b].daysShort[a.getUTCDay()],
						w: a.getUTCDay(),
						N: 0 == a.getUTCDay() ? 7 : a.getUTCDay(),
						S: a.getUTCDate() % 10 <= h[b].suffix.length ? h[b].suffix[a.getUTCDate() % 10 - 1] : "",
						a: 2 == h[b].meridiem.length ? h[b].meridiem[12 >
							a.getUTCHours() ? 0 : 1] : "",
						g: 0 == a.getUTCHours() % 12 ? 12 : a.getUTCHours() % 12,
						G: a.getUTCHours(),
						i: a.getUTCMinutes(),
						s: a.getUTCSeconds()
					};
					b.m = (10 > b.n ? "0" : "") + b.n;
					b.d = (10 > b.j ? "0" : "") + b.j;
					b.A = b.a.toString().toUpperCase();
					b.h = (10 > b.g ? "0" : "") + b.g;
					b.H = (10 > b.G ? "0" : "") + b.G;
					b.i = (10 > b.i ? "0" : "") + b.i;
					b.s = (10 > b.s ? "0" : "") + b.s;
				}
				a = [];
				d = f.extend([], c.separators);
				for (var g = 0, p = c.parts.length; g < p; g++) {
					d.length && a.push(d.shift()), a.push(b[c.parts[g]]);
				}
				return a.join("");
			},
			convertViewMode: function(a) {
				switch (a) {
					case 4:
						;
					case "decade":
						a = 4;
						break;
					case 3:
						;
					case "year":
						a = 3;
						break;
					case 2:
						;
					case "month":
						a = 2;
						break;
					case 1:
						;
					case "day":
						a = 1;
						break;
					case 0:
						;
					case "hour":
						a = 0;
				}
				return a;
			},
			headTemplate: '<thead><tr><th class="prev"><i class="fa fa-angle-double-left"/></th><th colspan="5" class="switch"></th><th class="next"><i class="fa fa-angle-double-right"/></th></tr></thead>',
			contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
			footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
		};
	e.template = '<div class="datetimepicker"><div class="datetimepicker-minutes"><table class=" table-condensed">' + e.headTemplate + e.contTemplate + e.footTemplate + '</table></div><div class="datetimepicker-hours"><table class=" table-condensed">' + e.headTemplate + e.contTemplate + e.footTemplate + '</table></div><div class="datetimepicker-days"><table class=" table-condensed">' + e.headTemplate + "<tbody></tbody>" + e.footTemplate + '</table></div><div class="datetimepicker-months"><table class="table-condensed">' +
		e.headTemplate + e.contTemplate + e.footTemplate + '</table></div><div class="datetimepicker-years"><table class="table-condensed">' + e.headTemplate + e.contTemplate + e.footTemplate + "</table></div></div>";
	f.fn.datetimepicker.DPGlobal = e;

	 var url= location.search.split('?')[1];
	 console.log(url);
      if(url=="type=3"){
  		$(".mm_cog_l_list").find("li").eq($(".mm_cog_l_list").find('li').length-1).addClass("mm_cog_list_active").siblings().removeClass();
         $('.mm_cog_item').eq(2).addClass("mm_cog_active").siblings().removeClass("mm_cog_active")
      }else if(url=="type=4"){
         $('.mm_cog_item').eq(2).addClass("mm_cog_active").siblings().removeClass("mm_cog_active");
		 $(".mm_cog_l_list").find("li").eq($(".mm_cog_l_list").find('li').length-1).addClass("mm_cog_list_active").siblings().removeClass();
      }
})(window.jQuery);